package com.xiaoshuidi.cloud.module.member.api.index;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.member.enums.AppIndexPageItemEnum;
import com.xiaoshuidi.cloud.module.member.service.index.AppIndexPageConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
public class AppIndexApiImpl implements AppIndexApi{
    @Resource
    private AppIndexPageConfigService appIndexPageConfigService;

    @Override
    public CommonResult<Object> getIndexConfig(Integer id, String lat, String lon, Long apartmentId) {
        AppIndexPageItemEnum item = AppIndexPageItemEnum.getEnumByIndex(id);
        if (item != null) {
            Object vo = appIndexPageConfigService.getAppIndexConfig(item, lat, lon, apartmentId);
            return CommonResult.success(vo);
        } else {
            return CommonResult.success();
        }
    }
}
